<template>
  <!-- 上传厂家证照的表格modal -->
  <div>
    <basic-modal
      :modalOpt="modal"
      :buttonText="['', '关闭']"
      @onMakeSure="onPush"
      @closeModal="closeModal"
      :footer="footer"
    >
      <template #cusBtn> </template>
      <template>
        <batch-operat-btn v-if="editable" :isView="false" :addData="true" @onAddData="onAddData">
          <template #cusBtn> </template>
        </batch-operat-btn>
        <a-list-info :infoDatas="infoDatas" span="12" />
      </template>
    </basic-modal>
  </div>
</template>

<script>
import basicModal from '@/views/app/biz/common/basicModal'
import aListTable from '@/views/app/biz/common/aListTable'
import aListInfo from '@/views/app/biz/common/aListInfo'
import batchOperatBtn from '@/views/app/biz/common/batchOperatBtn'

import { getInfoByPid } from './manufacturer'
import {infoDatas} from './dataConfig'
export default {
  components: {
    basicModal,
    aListTable,
    batchOperatBtn,
    aListInfo
  },
  data() {
    return {
      footer: undefined,
      editable: false,
      loading: false,
      modal: {
        modalVisible: false,
        modalTitle: '审核证照',
        modalWidth: '80vw'
      },
      infoDatas:infoDatas,
      listdata: [],
      listKey: 0,
      pid: '',
      zzPid: '',
      sysSeq: 0,
      loadings: false
    }
  },
  computed: {},
  mounted() {},
  methods: {
    // // 弹出模态框
    showModal(val, record) {
      this.pid = val.pid
      this.record = record
      this.modal.modalVisible = true
      this.modal.modalTitle = '查看详情'
      this.getSBypid(val)
      // this.getZZImgBypid(val2)
    },
    // 关闭模态详细框
    closeModal() {
      this.modal.modalVisible = false
      this.$emit('close')
    },
    closeModal2() {
      this.modal.modalVisible = false
      this.$emit('ok')
    },
    //
    onAddData() {
      this.$refs.addSellerLicChildModal.addModal(this.pid)
    },

    // 推送
    onPush() {
      this.showConfirm(this.record)
    },
    // 保存详细信息
    showConfirm(val) {
      const that = this
      this.$confirm({
        title: '是否确认推送？',
        content: '推送成功后请提醒客户审核！',
        onOk() {
          return new Promise((resolve, reject) => {
            resolve(pushInfo(val))
          })
            .then(res => {
              if (res && res.code && res.code === 'C1' && res.data) {
                that.$message.success({ content: '推送成功', duration: 2 })
                that.handleModalSaveOk()
              } else {
                that.$message.error({ content: res.code + '：' + res.message, duration: 2 })
              }
            })
            .catch(() => {
              that.$message.error({ content: '请求出错', duration: 2 })
            })
        },
        onCancel() {}
      })
    },
    // 得到初始化信息
    async getSBypid(val) {
      let res = await getInfoByPid(val)
      if (res && res.code && res.code === 'C1') {
        this.sysSeq = res.data.sysSeq
        for (const key in res.data) {
          for (const item of this.infoDatas) {
            if (key == item.id) {
              item.value = res.data[key]
            }
          }
        }
      }
    }
    // 得到初始化证照图片信息
    // async getZZImgBypid(val2) {
    //   this.loading=true
    //   let pa = {
    //     zhengZhaoPid: val2,
    //   }
    //   let res = await getZZImgByzzpid(pa)
    //   if (res && res.code && res.code === 'C1' && res.data) {
    //     this.listdata = res.data
    //     this.loading=false
    //   }
    //   console.log(res)
    // },
  }
}
</script>

<style>
.recordBox {
  width: 100%;
  min-height: 80px;
}
</style>
